import { queryNews } from '../services/news';

export default {
  namespace: 'news',

  state: {
    data: {},
    ok: false,
  },

  subscriptions: {},

  effects: {
    *fetch({ payload }, { call, put }) {
      // eslint-disable-line
      const res = yield call(queryNews, payload);
      yield put({
        type: 'queryList',
        payload: res || this.state,
      });
    },
  },

  reducers: {
    queryList(state, action) {
      console.log('action.payload:', action.payload);
      return { ...state, ...action.payload };
    },
  },
};
